<?php

/**

* @version $Id: searchxml.html.php 4955 2006-09-06 13:07:03Z predator $

* @package Joomla

* @subpackage SearchXML

* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.

* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php

* Joomla! is free software. This version may have been modified pursuant

* to the GNU General Public License, and as distributed it includes or

* is derivative of works licensed under the GNU General Public License or

* other free or open source software licenses.

* See COPYRIGHT.php for copyright notices and details.

*/

/* Modificado por Argenis Leon */



// no direct access

defined( '_VALID_MOS' ) or die( 'Restricted access' );



/**

* @package Joomla

* @subpackage Search

*/

class search_html {



	function openhtml( $params ) {

		if ( $params->get( 'page_title' ) ) {

			?>

			<div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">

				<?php echo $params->get( 'header' ); ?>

			</div>

			<?php

		}

	}



	function searchbox( $searchword, &$lists, $params ) {

		global $Itemid;

		?>

		<form action="index.php" method="get">

		<input type="hidden" name="option" value="com_search" />

		<input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />

		<table class="contentpaneopen<?php echo $params->get( 'pageclass_sfx' ); ?>">

			<tr>

				<td nowrap="nowrap">

					<label for="search_searchword">

						<?php echo _PROMPT_KEYWORD; ?>:

					</label>

				</td>

				<td nowrap="nowrap">

					<input type="text" name="searchword" id="search_searchword" size="30" maxlength="20" value="<?php echo stripslashes($searchword);?>" class="inputbox" />

				</td>

				<td width="100%" nowrap="nowrap">

					<input type="submit" name="submit" value="<?php echo _SEARCH_TITLE;?>" class="button" />

				</td>

			</tr>

			<tr>

				<td colspan="3">

					<?php echo $lists['searchphrase']; ?>

				</td>

			</tr>

			<tr>

				<td colspan="3">

					<label for="search_ordering">

						<?php echo _CMN_ORDERING;?>:

					</label>

					<?php echo $lists['ordering'];?>

				</td>

			</tr>

		</table>

		</form>

		<?php

	}



	function searchintro( $searchword, $params ) {

		?>

		<table class="searchintro<?php echo $params->get( 'pageclass_sfx' ); ?>">

		<tr>

			<td colspan="3" align="left">

			<?php echo _PROMPT_KEYWORD . ' <b>' . stripslashes($searchword) . '</b>'; ?>

		<?php

	}



	function message( $message, $params ) {

			eval ('echo "'.$message.'";'); 

	}



	function displaynoresult() {

	}



	function display( &$rows, $params, $pageNav, $limitstart, $limit, $total, $totalRows, $searchword ) {

		global $mosConfig_hideCreateDate;

		global $mosConfig_live_site, $option, $Itemid;
		
		$newLink ="";

		

		$c 			= count ($rows);

		$searchword = urldecode( $searchword );

	

		// number of matches found

		//eval ('echo "'._CONCLUSION.'";');



		echo "<pagesCounter>".$pageNav->writePagesCounter()."</pagesCounter>".chr(10);
			$ordering 		= strtolower( strval( mosGetParam( $_REQUEST, 'ordering', 'newest' ) ) );
			$searchphrase 	= strtolower( strval( mosGetParam( $_REQUEST, 'searchphrase', 'any' ) ) );
			$searchphrase	= htmlspecialchars($searchphrase);
			$link = $mosConfig_live_site ."/index.php?option=$option&amp;Itemid=$Itemid&amp;searchword=$searchword&amp;searchphrase=$searchphrase&amp;ordering=$ordering";

			//echo $pageNav->getLimitBox( $link );
				$z		= $limitstart + 1;
				$end 	= $limit + $z;
				if ( $end > $total ) {
					$end = $total + 1;
				}
				echo "<results>".chr(10);
				for( $i=$z; $i < $end; $i++ ) {
					echo "<display>".chr(10);
					$row = $rows[$i-1];
					if ($row->created) {
						$created = mosFormatDate ($row->created, _DATE_FORMAT_LC);
					} else {
						$created = '';
					}
						
							if ( $row->href ) {
								$row->href = ampReplace( $row->href );
								if ($row->browsernav == 1 ) {
									echo "<link>".preg_replace( "/com_content/", "com_contentxml", sefRelToAbs($row->href))."</link>".chr(10);
							
								} else {
									echo "<link>".preg_replace( "/com_content/", "com_contentxml", sefRelToAbs($row->href))."</link>".chr(10);
										
								}
									
							}
							echo "<title>".$row->title."</title>".chr(10);
							if ( $row->href ) {
							}
							if ( $row->section ) {
								echo "<section>".$row->section."</section>".chr(10); 
							}
							echo "<text><![CDATA[".ampReplace( $row->text )."]]></text>".chr(10);

						if ( !$mosConfig_hideCreateDate ) {
							echo "<created>".$created."</created>".chr(10); 
						}
						echo "</display>".chr(10);
				}
				echo "</results>".chr(10);
	}

	function conclusion( $searchword, $pageNav ) {
		global $mosConfig_live_site, $option, $Itemid;
		
		$ordering 		= strtolower( strval( mosGetParam( $_REQUEST, 'ordering', 'newest' ) ) );
		$searchphrase 	= strtolower( strval( mosGetParam( $_REQUEST, 'searchphrase', 'any' ) ) );	
		
		$searchphrase	= htmlspecialchars($searchphrase);
		
		$link 			= $mosConfig_live_site ."/index.php?option=$option&Itemid=$Itemid&searchword=$searchword&searchphrase=$searchphrase&ordering=$ordering";
		
		echo $pageNav->writePagesLinks( $link ); 
	}
}
?>